package com.taotao.thread.Test1;

import java.util.concurrent.CyclicBarrier;

/**
 * @author wangjin
 * @title: T07_TestCyclicBarrier
 * @projectName thread
 * @description: TODO
 * @date 2022/5/4 0004 9:55
 */
public class T07_TestCyclicBarrier {
    public static void main(String[] args) {
        CyclicBarrier barrier=new CyclicBarrier(20,()->
                System.out.println("满人发车。"));
      /*  CyclicBarrier barrier=new CyclicBarrier(20, new Runnable() {
            @Override
            public void run() {
                System.out.println("满人,发车");
            }
        });*/
        for (int i= 0; 0 < 100; i++) {
            new Thread(()->{
               try {
                   barrier.wait();
               }catch (Exception e){
                   e.getMessage();
               }
            }).start();
        }
    }
}
